Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#8] 콘텐츠 검색 및 필터링 기능 구현 쿼리 최적화 #9

Merged
merged 6 commits into from
Oct 1, 2024

Conversation

wktls63
Copy link
Collaborator

@wktls63 wktls63 commented Oct 1, 2024

콘텐츠 검색 및 필터링 기능 구현

변경 사항

  • 콘텐츠 목록 조회 시 제목(title)과 카테고리(category)로 필터링할 수 있는 기능 추가
  • GET /contents/?title=Test&category=Movie와 같은 방식으로 검색 가능
  • 콘텐츠 목록을 필터링하여 필요한 데이터만 조회할 수 있도록 최적화

변경된 파일

  • app/content.py: 검색 및 필터링 기능 추가
  • tests/test_content.py: 검색 및 필터링 기능에 대한 테스트 추가

변경 이유

  • 사용자가 특정 콘텐츠를 제목 또는 카테고리로 필터링하여 검색할 수 있도록 기능 개선
  • 콘텐츠 수가 증가함에 따라 성능 최적화를 통해 불필요한 데이터 조회를 방지

체크리스트

  • 제목으로 콘텐츠를 필터링할 수 있는지 확인 (title 쿼리 파라미터)
  • 카테고리로 콘텐츠를 필터링할 수 있는지 확인 (category 쿼리 파라미터)
  • 제목과 카테고리 모두로 필터링할 수 있는지 확인
  • 필터 조건이 없을 때 전체 콘텐츠가 정상적으로 조회되는지 확인
  • 데이터베이스 쿼리 최적화를 통해 불필요한 데이터 로드를 방지
  • 기존 기능(생성, 삭제)이 정상적으로 작동하는지 확인

테스트 방법

  1. 가상 환경 실행: source venv/bin/activate
  2. 서버 실행: uvicorn app.main:app --reload
  3. pytest를 사용하여 테스트 실행:
    pytest
  4. 테스트 항목:
    • 제목 필터링: GET /contents/?title=Test로 제목이 "Test"인 콘텐츠 조회
    • 카테고리 필터링: GET /contents/?category=Movie로 카테고리가 "Movie"인 콘텐츠 조회
    • 제목과 카테고리 모두 필터링: GET /contents/?title=Test&category=Movie
    • 필터 조건 없이 전체 콘텐츠 조회: GET /contents/

추가된 테스트

  • test_get_content_with_title_filter: 제목으로 콘텐츠 필터링 테스트
  • test_get_content_with_category_filter: 카테고리로 콘텐츠 필터링 테스트
  • test_get_content_with_title_and_category_filter: 제목과 카테고리 모두로 필터링 테스트

참고 사항

  • 성능 최적화를 위해 불필요한 데이터 로드 방지를 적용했으며, 필터링 쿼리에 인덱스를 활용하여 성능을 개선했습니다.

@wktls63 wktls63 self-assigned this Oct 1, 2024
Copy link

sonarcloud bot commented Oct 1, 2024

@wktls63 wktls63 merged commit 3379dff into main Oct 1, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant